<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function fn(){
            var ytext = document.getElementById('ytext');
            var mtext = document.getElementById('mtext');
            ytext = ytext.value;
            var a,b,c,d;
            a = parseInt(ytext/1000);
            b = parseInt(ytext/100)%10;
            c = parseInt(ytext/10)%10;
            d = ytext%10;
            a1 = (a+5)%10;
            b1 = (b+5)%10;
            c1 = (c+5)%10;
            d1 = (d+5)%10;
            var num = ''+d1+c1+b1+a1
            mtext.value = num;
        }
    </script>
</head>
<body>
    <input type="text" id="ytext">
    <button onclick="fn()">加密</button>
    <input type="text" id="mtext">
</body>
</html>